#include <iostream>
using namespace std;

const int N = 1e5+10;

int e[N],ne[N],h,id;

void push_front(int x){
    id++;
    e[id] = x;
    ne[id] = ne[h];
    ne[h] = id;
}

void print(){
    for(int i = ne[h];i;i = ne[i]){
        cout << e[i] << " ";
    }
    cout << endl << endl;
}

int find(int x){
    for(int i = ne[h];i;i = ne[i]){
        if(e[i] == x){
            return i;
        }
        return -1;
    }
}

int main(){
    for(int i = 1;i <= 5;i++){
        push_front(i);
    }
    print();

    cout << find(2) << endl;
    cout << find(3) << endl;
    cout << find(6) << endl;
    return 0;
}